{% extends "personal_center.html" %}
{% block main_content %}
    {% if get_flashed_messages()[0] %}
        <div class="alert alert-danger alert-dismissible fade show" role="alert">
          <strong>错误提示!</strong> {{get_flashed_messages()[0]}}
          <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
    {% endif %}
    <form action="{{url_for('category.list')}}" method="post" class="form-inline">
      {{form.hidden_tag()}}
      <div class="input-group mb-2 mr-sm-2">
          {{form.name(class="form-control", placeholder="分类名称")}}
      </div>
      {{form.submit(class="btn btn-primary mb-2")}}
    </form>
    <table class="table">
        <thead>
            <tr>
                <th>分类名称</th>
                <th>博客数量</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for item in list %}
                <tr>
                    <td>{{item.name}}</td>
                    <td>{{item.article_count}}</td>
                    <td>
                        <button class="btn btn-primary btn-sm">编辑</button>
                        <a href="{{url_for('category.delete', id=item.id)}}" class="btn btn-danger btn-sm">删除</a>
                    </td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
{% endblock %}